package com.cssw.fyzb.busi.api.live;

import com.cssw.fyzb.core.model.vo.live.OperLiveVo;
import com.cssw.fyzb.busi.service.live.AnchorService;
import com.ydn.appserver.Action;
import com.ydn.appserver.Request;
import com.ydn.appserver.Response;
import com.ydn.appserver.annotations.Function;
import com.ydn.appserver.annotations.Parameter;
import com.ydn.appserver.annotations.Type;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @description: 查看是否有直播权限
 * @author: zzf
 * @time: 2020/12/25 15:30
 */
@Function(description = "查看是否有直播权限", parameters = {
        @Parameter(name = "userId", type = Type.String, description = "用户ID", required = true)
})
@Component
public class LiveVerification implements Action {
    private final static Logger logger = LoggerFactory.getLogger(LiveVerification.class);

    @Autowired
    private AnchorService anchorService;

    @Override
    public Response execute(Request request) throws Exception {
        Long userId = request.getLong("userId");
        try {
            List<OperLiveVo> vo = anchorService.liveVerification(userId);
            return Response.success().put("list", vo);
        } catch (Exception e) {
            logger.debug("", e);
            return Response.fail("查询失败");
        }
    }
}
